package com.itheima.aop;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(value = {"classpath*:spring*.xml"})
public class test01 {

    @Autowired
    private JedisPool jedisPool;
    @Test
    public  void test01() {

        Jedis jedis = jedisPool.getResource();
        //3. 使用

        jedis.zadd("mysortedset",1,"checkitem_add");
        jedis.zadd("mysortedset",3,"亚瑟");
        jedis.zadd("mysortedset",30,"后裔");
        jedis.zadd("mysortedset",55,"孙悟空");
        Set<String> mysortedset = jedisPool.getResource().zrange("mysortedset", 0, -1);
        if(mysortedset.size()!=0){
            for (String s : mysortedset) {
                System.out.println(s+"-"+jedis.zscore("mysortedset",s));
            }
        }
        Double zscore = jedis.zscore("mysortedset", "wang");
        System.out.println(zscore);
    }
    @Test
    public void test02() throws Exception{
        double d = 12/13;
        System.out.println(d);

    }
    @Test
    public void test03() throws Exception{
        HashMap<String, Object> map = new HashMap<>();
        map.put("k1","1");
        map.put("k2","3");
        map.put("k3","5");

        Iterator it = map.keySet().iterator();
        // 键和值
        String key = null;
        String value = null;
        while (it.hasNext()) {
            key = (String) it.next();
            value = (String) map.get(key);
            System.out.println("key:" + key + "---" + "value:" + value);
        }

    }

}
